package edu.ccut.saturn.workflow.startWorkFlowModule.code;

import edu.ccut.saturn.component.DefaultComponent;
import edu.ccut.saturn.component.IParameterContext;
import edu.ccut.saturn.workflow.model.ActivityInfo;
import edu.ccut.saturn.workflow.model.StartInfo;
import edu.ccut.saturn.workflow.model.WorkFlowInfo;
/**
 * 处理下一活动
 * @author tony
 *
 */
public class DisposeNextActivity extends DefaultComponent {
	@SuppressWarnings("unchecked")
	@Override
	public void execute(IParameterContext parameterContext) throws Exception {
		WorkFlowInfo workFlowInfo = (WorkFlowInfo) parameterContext
				.getParameterValue(1);
		// 获得开始节点信息
		StartInfo startInfo = workFlowInfo.getStartInfo();
		ActivityInfo startActivityNext = workFlowInfo
				.getActivityInfoById(startInfo.getNext());
		// 开始活动的下一活动一定是一对一的，所以不用判断是否聚合，直接驱动下一活动
		parameterContext.addParameter(null, Object.class);
		parameterContext.setParameter(5, startActivityNext);// 为参数上下文设置第六参数--下一活动的Info
		IActivateActivity activateActivity = WorkFlowInstanceFactory
				.getActivateActivity(startActivityNext.getType());
		activateActivity.activate(parameterContext);// 激活活动
	}
}